package com.jason.campusinn.view;

import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.util.AttributeSet;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.yuandian.wanna.WannaApp;
import com.yuandian.wanna.utils.DisplayUtil;

/**
 * Created by yuandian on 2015/5/20.
 */
public class SelectedLargeImageView extends ImageView {
    public SelectedLargeImageView(Context context) {
        super(context);
    }

    public SelectedLargeImageView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public SelectedLargeImageView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @TargetApi(Build.VERSION_CODES.LOLLIPOP)
    public SelectedLargeImageView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }

    @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
    @Override
    protected void dispatchSetSelected(boolean selected) {
        super.dispatchSetSelected(selected);
        ViewGroup.LayoutParams params = getLayoutParams();
        this.measure(0,0);
        if (selected){
            params.width = params.height = DisplayUtil.dip2px(70, WannaApp.getInstance().mScreenDensity);
        } else {
            params.height = params.width =  DisplayUtil.dip2px(60, WannaApp.getInstance().mScreenDensity);
        }
        setLayoutParams(params);
        invalidate();
    }
}
